/**
 * 病种入组病例管理初始化
 */
var CusIndexDetail = [
    {
        id: "CusIndexDetailTable",	//表格id
        seItem: null,		//选中的条目
        table: null,
        layerIndex: -1,
        hospID: null,
        episodeId: 0,
        clicked: false
    },
    {
        id: "CusIndexDetailTable1",	//表格id
        seItem: null,		//选中的条目
        table: null,
        layerIndex: -1,
        hospID: null,
        episodeId: 0,
        clicked: false
    }
];

/**
 * 初始化表格的列
 */
CusIndexDetail.initColumn = function () {
    var columnArr = [
        {
            width: 30, align: "center", valign: 'middle', sortable: true, formatter: function (value, row, index) {
                //获取每页显示的数量
                var pageSize = $('#CusIndexDetailTable').bootstrapTable('getOptions').pageSize;
                //获取当前是第几页
                var pageNumber = $('#CusIndexDetailTable').bootstrapTable('getOptions').pageNumber;
                //返回序号，注意index是从0开始的，所以要加上1
                return pageSize * (pageNumber - 1) + index + 1;
            }
        },
        {title: '院区', field: 'admHospDesc', width: 120, align: 'left', valign: 'middle'},
        {title: '科室', field: 'admLocDesc', width: 120, align: 'left', valign: 'middle'},
        {title: '病案号', field: 'mrNum', width: 100, align: 'left', valign: 'middle'},
        {title: '就诊号', field: 'id', width:100, align: 'left', valign: 'middle'},
        {title: '姓名', field: 'name', width: 100, align: 'left', valign: 'middle'},
        {title: '性别', field: 'sex', width: 30, align: 'center', valign: 'middle'},
        {title: '年龄', field: 'age', width: 30, align: 'center', valign: 'middle'},
        {title: '主管医生', field: 'admDocName', width: 80, align: 'left', valign: 'middle'},
        {title: '入院日期', field: 'admDate', width: 120, align: 'left', valign: 'middle'},
        {title: '出院日期', field: 'dishDate', width: 120, align: 'left', valign: 'middle'},
        {title: '病种名称', field: 'entityName', width: 140, align: 'left', valign: 'middle'}
    ];

    return columnArr;
};

CusIndexDetail.initColumn1 = function () {
    var columnArr = [
        {
            width: 30, align: "center", valign: 'middle', sortable: true, formatter: function (value, row, index) {
                //获取每页显示的数量
                var pageSize = $('#CusIndexDetailTable1').bootstrapTable('getOptions').pageSize;
                //获取当前是第几页
                var pageNumber = $('#CusIndexDetailTable1').bootstrapTable('getOptions').pageNumber;
                //返回序号，注意index是从0开始的，所以要加上1
                return pageSize * (pageNumber - 1) + index + 1;
            }
        },
        {title: '院区', field: 'admHospDesc', width: 120, align: 'left', valign: 'middle'},
        {title: '科室', field: 'admLocDesc', width: 120, align: 'left', valign: 'middle'},
        {title: '病案号', field: 'mrNum', width: 100, align: 'left', valign: 'middle'},
        {title: '就诊号', field: 'id', width:100, align: 'left', valign: 'middle'},
        {title: '姓名', field: 'name', width: 100, align: 'left', valign: 'middle'},
        {title: '性别', field: 'sex', width: 30, align: 'center', valign: 'middle'},
        {title: '年龄', field: 'age', width: 30, align: 'center', valign: 'middle'},
        {title: '主管医生', field: 'admDocName', width: 80, align: 'left', valign: 'middle'},
        {title: '入院日期', field: 'admDate', width: 120, align: 'left', valign: 'middle'},
        {title: '出院日期', field: 'dishDate', width: 120, align: 'left', valign: 'middle'},
        {title: '病种名称', field: 'entityName', width: 140, align: 'left', valign: 'middle'}
    ];

    return columnArr;
};

$(function () {
    $('#winConfirmInfo').dialog({
        title: '',
        iconCls: "icon-w-edit",
        closed: true,
        modal: true,
        isTopZindex: true
    });
    var defaultColunms = CusIndexDetail.initColumn();
    var table = new BSTable(CusIndexDetail[0].id, Sys.backendPath + "/analysis/cusindexstat/detailslist1", defaultColunms);
    table.setPaginationType("server");
    table.setPageSize(8);
    table.setShowRefresh(false);
    table.setShowColumns(false);
    table.setShowToggle(false);
    table.setShowExport(false);
    var b_height = document.documentElement.clientHeight;
    table.setHeight(320);
    table.set("admDocId", $("#docId").val());
    table.set("admLocId", $("#locId").val());
    table.set("entityId", $("#entityId").val());
    table.set("endDate", $("#endDate").val());
    table.set("startDate", $("#startDate").val());
    table.set("epIds", $("#epIds").val());
    table.set("type",1)
    CusIndexDetail[0].table = table.init();

    var defaultColunms1 = CusIndexDetail.initColumn1();
    var table = new BSTable(CusIndexDetail[1].id, Sys.backendPath + "/analysis/cusindexstat/detailslist1", defaultColunms1);
    table.setPaginationType("server");
    table.setPageSize(8);
    table.setShowRefresh(false);
    table.setShowColumns(false);
    table.setShowToggle(false);
    table.setShowExport(false);
    var b_height = document.documentElement.clientHeight;
    table.setHeight(320);
    table.set("admDocId", $("#docId").val());
    table.set("admLocId", $("#locId").val());
    table.set("entityId", $("#entityId").val());
    table.set("endDate", $("#endDate").val());
    table.set("startDate", $("#startDate").val());
    table.set("epIdsOpp", $("#epIdsOpp").val());
    table.set("type",-1)

    CusIndexDetail[1].table = table.init();
});

//在Jquery里格式化Date日期时间数据
function timeStamp2String(time) {
    var datetime = new Date();
    datetime.setTime(time);
    var year = datetime.getFullYear();
    var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1;
    var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate();
    return year + "-" + month + "-" + date;
}
